# coding=utf-8
import ConfigParser
import os

WEIXIN_SECRET = ""
WEIXIN_CORP_ID = ''

WEIXIN_AGENT_ID = 1

MODE = 'TEST'
# MODE = 'PRODUCT

DB_URL = 'sqlite:///data/ccc.db'

_CONFIG_FILES = [
    os.path.expanduser('~/.config/ccc/config.ini'),
    '/etc/cadts/ccc/config.ini',
    'conf/config.ini',
]

_config_file = None
for config_file in _CONFIG_FILES:
    if os.path.isfile(config_file):
        _config_file = config_file
        break

if not _config_file:
    raise Exception('config files not exists')

if os.path.exists(_config_file):
    parser = ConfigParser.ConfigParser()
    parser.read(_config_file)
    WEIXIN_APP_ID = parser.get('weixin', 'app_id')
    WEIXIN_SECRET = parser.get("weixin", 'secret')
    WEIXIN_TOKEN = parser.get("weixin", 'token')
    DB_URL = parser.get('db', 'url')
    MODE = parser.get('server', 'mode')
    REGISTER_SECRET = parser.get('server', 'register_secret').decode('utf-8')
    ROOT_NAME = parser.get('server', 'root_name')
    BAIDU_AK = parser.get('baidu', 'ak')
    DEPARTMENT_NAME = parser.get('server', 'department_name').decode('utf-8')
else:
    raise Exception(u'配置文件{}未找到'.format(_config_file))
